<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>牛只管理</title>
		<link href="css/mui.min.css" rel="stylesheet" type="text/css">
		<link href="css/mui.picker.min.css" rel="stylesheet" type="text/css">
		<link href="css/new_file.css" rel="stylesheet" type="text/css">
		<link href="css/mui.picker.min.css" rel="stylesheet" >
		
		<script charset="UTF-8" src="js/config.js"></script>
		<script charset="UTF-8" src="js/testActivityName.js"></script>
		<script charset="UTF-8" src="js/core.js"></script>
		<script charset="UTF-8" src="js/cipher-core.js"></script>
		<script charset="UTF-8" src="js/tripledes.js"></script>
		<script charset="UTF-8" src="js/mode-ecb.js"></script>
		<script src="js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/spin.min.js"></script>
		<script charset="UTF-8" src="js/mui.min.js"></script>
		<script src="js/echarts.min.js"></script>
		<script charset="UTF-8" src="js/simple.tool.js"></script>
		<script charset="UTF-8" src="js/mui.picker.min.js"></script>
	</head>

	<body>

		<div class="head-zhjf">
			<img src="images/fanhui@3x.png" class="ryjk-tx" onclick="fanhuiss()">
			<p style="color: white;">修改牛只信息</p>
		</div>

		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">奶牛编号</div>
			</div>
			<div class="moban-lb-r">
				<p id="cowCode" style="/* display: table-cell; */vertical-align: middle;text-align: left;margin-top: 12px;"></p>
			</div>
			<div class="clear"></div>
		</div>

		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">出生日期</div>
			</div>
			<div class="moban-lb-r">
				<input type="text" onfocus=this.blur() onclick="dtPicker('birthday')" id="birthday" style=" margin-top: 1px;"/>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">产犊日期</div>
			</div>
			<div class="moban-lb-r">
				<input type="text" onfocus=this.blur() onclick="dtPicker('deliveryDate')" id="deliveryDate" style=" margin-top: 1px;"/>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">上次配种日期</div>
			</div>
			<div class="moban-lb-r">
				<input type="text" onfocus=this.blur() onclick="dtPicker('Last_mating')" id="Last_mating" style=" margin-top: 1px;"/>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">胎次</div>
			</div>
			<div class="moban-lb-r">
				<input type="text" name="parity" id="parity" style=" margin-top: 1px;" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"/>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">繁殖状态</div>
			</div>
			<div class="moban-lb-r">
				<select id="reproductive_status" style="/* display: table-cell; */vertical-align: middle;text-align: left;margin-top: 11px;">
					<option >无记录</option>
					<option value="空怀">空怀</option>
					<option value="适配空怀">适配空怀</option>
					<option value="已配待检">已配待检</option>
					<option value="参配已孕">参配已孕</option>
				</select>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">牛舍</div>
			</div>
			<div class="moban-lb-r">
				<p id="noApplicationRecord" style="/* display: table-cell; */vertical-align: middle;text-align: left;margin-top: 12px;"></p>
			</div>

			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">设备编号</div>
			</div>
			<div class="moban-lb-r">
				<input id="deviceSN" onclick="deviceSNBut()" type="text" value="请输入" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;margin-top: 2px;" class="shuru-jine">
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">类型</div>
			</div>
			<div class="moban-lb-r">
				<select id="cowTypes" style="/* display: table-cell; */vertical-align: middle;text-align: left;margin-top: 11px;">

				</select>
			</div>
			<div class="clear"></div>
		</div>

		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">状态</div>
			</div>
			<div class="moban-lb-r">
				<select id="statuss" style="/* display: table-cell; */vertical-align: middle;text-align: left;margin-top: 11px;">

				</select>
			</div>
			<div class="clear"></div>
		</div>
		
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">生理状态</div>
			</div>
			<div class="moban-lb-r">
				<select id="cowPhysiologyID" style="/* display: table-cell; */vertical-align: middle;text-align: left;margin-top: 11px;">

				</select>
			</div>
			<div class="clear"></div>
		</div>
		
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">耳号1</div>
			</div>
			<div class="moban-lb-r">
				<input id="overbiStr1"  type="text" value="选填" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;margin-top: 2px;" class="shuru-jine">
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">耳号2</div>
			</div>
			<div class="moban-lb-r">
				<input id="overbiStr2"  type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;margin-top: 2px;" class="shuru-jine">
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">怀孕史</div>
			</div>
			<div class="moban-lb-r">
				<select id="cowConceiveData" style="/* display: table-cell; */vertical-align: middle;text-align: left;margin-top: 11px;">

				</select>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">品种</div>
			</div>
			<div class="moban-lb-r">
				<select id="cowVarietyData" style="/* display: table-cell; */vertical-align: middle;text-align: left;margin-top: 11px;">

				</select>
			</div>
			<div class="clear"></div>
		</div>
		
		
		<div class="tijiao" style="position: static">
			<button type="button" class="tijiao-btn" onclick="cowModify()">修改</button>

		</div>
		<script>

			//$('#cowCode').val(currentdate);
			
			//cowPhysiology
			var cowTypes = document.getElementById('cowTypes');
			var statuss = document.getElementById('statuss');
			var cowPhysiologyID = document.getElementById('cowPhysiologyID');
			var cowVarietyData = document.getElementById('cowVarietyData');
			var cowConceiveData = document.getElementById('cowConceiveData');
			
			var cowType = JSON.parse(localStorage.getItem('cowType'));
			var cowStatus = JSON.parse(localStorage.getItem('cowStatus'));
			var cowPhysiology = JSON.parse(localStorage.getItem('cowPhysiology'));
			var cowVarietyArr = JSON.parse(localStorage.getItem('cowVarietyArr'));
			var cowConceiveArr = JSON.parse(localStorage.getItem('cowConceiveArr'));
			console.log(cowVarietyArr);
			console.log(cowConceiveArr);

			function setDiv1(item) {
				var div = '<select><option id="' + item.cowTypeID + '">' +
					item.cowType +
					'</option></select>'
				return div
			}

			function setDiv2(item) {
				var div = '<select><option id="' + item.statusID + '">' +
					item.status +
					'</option></select>'
				return div
			}
			function setDiv3(item) {
				var div = '<select><option id="' + item.cowConceiveID + '">' +
					item.cowConceive  +
					'</option></select>'
				
				return div
			}
			function setDiv4(item) {
				var div = '<select><option id="' + item.cowVarietyID + '">' +
					item.cowVariety +
					'</option></select>'
				return div
			}
			function setDiv5(item) {
				var div = '<select><option id="' + item.cowPhysiologyID + '">' +
					item.cowPhysiology +
					'</option></select>'
				return div
			}

		

			function getnoApplicationData1() {
				var html = ''
				for(var i = 0; i < cowType.length; i++) {
					html += setDiv1(cowType[i])
				}
				cowTypes.innerHTML = html
			}

			function getnoApplicationData2() {
				var html = ''
				for(var i = 0; i < cowStatus.length; i++) {
					html += setDiv2(cowStatus[i])
				}
				statuss.innerHTML = html
			}
			function getnoApplicationData3() {
				var html = ''
				for(var i = 0; i < cowConceiveArr.length; i++) {
					html += setDiv3(cowConceiveArr[i])
				}
				cowConceiveData.innerHTML = html
				
			}
			function getnoApplicationData4() {
				var html = ''
				for(var i = 0; i < cowVarietyArr.length; i++) {
					html += setDiv4(cowVarietyArr[i])
				}
				cowVarietyData.innerHTML = html
			}
			function getnoApplicationData5() {
				var html = ''
				for(var i = 0; i < cowPhysiology.length; i++) {
					html += setDiv5(cowPhysiology[i])
				}
				cowPhysiologyID.innerHTML = html
			}
			
			window.onload = getnoApplicationData1();
			window.onload = getnoApplicationData2();
			window.onload = getnoApplicationData3();
			window.onload = getnoApplicationData4();
			window.onload = getnoApplicationData5();
			
			

			var modifyDeviceSN = JSON.parse(localStorage.getItem('modifyDeviceSN'));
			var  equipmentDetails = JSON.parse(localStorage.getItem('equipmentDetails'));
			console.log(modifyDeviceSN);
			var Cattlemodify = JSON.parse(localStorage.getItem('Cattlemodify'));
			if(Cattlemodify == 100) {
				if (modifyDeviceSN == '') {
					var str = equipmentDetails.deviceCode;
				}else {
					var str = modifyDeviceSN.deviceCode;
				}
				
				var str2 = JSON.parse(localStorage.getItem('birthdayNumber'));
				var str4 = JSON.parse(localStorage.getItem('deviceSNNumber'));
				var str5 = JSON.parse(localStorage.getItem('cowTypeNumber'));
				var str6 = JSON.parse(localStorage.getItem('statusNumber'));
				var str7 = JSON.parse(localStorage.getItem('overbiString1'));
				var str8 = JSON.parse(localStorage.getItem('overbiString2'));
				var str9 = JSON.parse(localStorage.getItem('cowVarietyStr'));
				var str10 = JSON.parse(localStorage.getItem('cowConceiveStr'));
				var str11 = JSON.parse(localStorage.getItem('cowPhysiologyIDNumber'));
				var str12 = JSON.parse(localStorage.getItem('deliveryDate'));
				var str13 = JSON.parse(localStorage.getItem('Last_mating'));
				var str14 = JSON.parse(localStorage.getItem('reproductive_status'));
				var str15 = JSON.parse(localStorage.getItem('parity'));
				if(str12=="无记录"){
					str12='';
				}
				if (str13=="无记录"){
					str13='';
				}
				if (str14=="无记录"){
					str14='';
				}
				$("#reproductive_status").val(str14);
				$("#Last_mating").val(str13);
				$("#parity").val(str15);
				$("#deliveryDate").val(str12);
				$('#cowCode').html(equipmentDetails.cowCode);
				$("#birthday").val(str2);
				$('#noApplicationRecord').html(equipmentDetails.houseName);
				$("#deviceSN").val(str);
				$("#cowTypes").val(str5);
				$("#statuss").val(str6);
				$("#cowPhysiologyID").val(str11);
				$("#overbiStr1").val(str7);
				$("#overbiStr2").val(str8);
				$("#cowConceiveData").val(str9);
				$("#cowVarietyData").val(str10);
			}else{
			var str12 = equipmentDetails.DeliveryDate;
			var str13 = equipmentDetails.Last_mating;
			var str14 = equipmentDetails.reproductive_status;
			var str15 = equipmentDetails.parity;
			if(str14=="无记录"){
				str14='';
			}
			if(str12=="无记录"){
				str12='';
			}
			if (str13=="无记录"){
				str13='';
			}
			console.log(equipmentDetails);
			$('#cowCode').html(equipmentDetails.cowCode);
			$("#birthday").val(equipmentDetails.birthday);
			$("#deliveryDate").val(str12);
			$("#Last_mating").val(str13);
			$("#parity").val(str15);
			$("#reproductive_status").val(str14);
			$('#noApplicationRecord').html(equipmentDetails.houseName);
			$("#deviceSN").val(equipmentDetails.deviceCode);
			$("#cowTypes").val(equipmentDetails.cowType);
			$("#statuss").val(equipmentDetails.status);
			$("#overbiStr1").val(equipmentDetails.overbit1);
			$("#overbiStr2").val(equipmentDetails.overbit2);
			$("#cowConceiveData").val(equipmentDetails.conceive);
			$("#cowVarietyData").val(equipmentDetails.variety);
			$("#cowPhysiologyID").val(equipmentDetails.physiology);
			}
			function deviceSNBut() {
				localStorage.setItem('birthdayNumber', JSON.stringify($("#birthday").val()));
				localStorage.setItem('deliveryDate', JSON.stringify($("#deliveryDate").val()));
				localStorage.setItem('Last_mating', JSON.stringify($("#Last_mating").val()));
				localStorage.setItem('parity', JSON.stringify($("#parity").val()));
				localStorage.setItem('reproductive_status', JSON.stringify($("#reproductive_status").val()));
				localStorage.setItem('deviceSNNumber', JSON.stringify($("#deviceSN").val()));
				localStorage.setItem('cowTypeNumber', JSON.stringify($("#cowTypes").val()));
				localStorage.setItem('statusNumber', JSON.stringify($("#statuss").val()));
				localStorage.setItem('cowPhysiologyIDNumber', JSON.stringify($("#cowPhysiologyID").val()));
				localStorage.setItem('useID', JSON.stringify(equipmentDetails.cowID));
				localStorage.setItem('Cattlemodify', JSON.stringify(100));
				localStorage.setItem('overbiString1', JSON.stringify($("#overbiStr1").val()));
				localStorage.setItem('overbiString2', JSON.stringify($("#overbiStr2").val()));
				localStorage.setItem('cowConceiveStr', JSON.stringify($("#cowConceiveData").val()));
				localStorage.setItem('cowVarietyStr', JSON.stringify($("#cowVarietyData").val()));
				equipments();
			}
			function fanhuiss(){
				localStorage.setItem('Cattlemodify', JSON.stringify(0));
				Cattle1();
			}
		</script>
	</body>

</html>